package mavenWebProject;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface userMapper {
	
	/*
	 * 记录网站访问次数
	 */
	@Update("UPDATE tb_user SET time+=#{tempnum} WHERE username=#{temp}")
	public void updateTimes(@Param("temp")String temp,@Param("tempnum")int tempnum);
	/*
	 * 根据用户名查询所有信息
	 */
	@Select("SELECT * FROM tb_user WHERE username=#{username}")
	public List<user> selectByUsername(@Param("username")String username);
	/*
	 * 查询所有用户记录
	 */
	@Select("SELECT * FROM tb_user")
	public List<user> selectAllUser();
	/*
	 * 根据用户id查询所有信息
	 */
	@Select("SELECT * FROM tb_user WHERE id=#{id}")
	public List<user> selectById(@Param("id")int id);
	/*
	 * 判断账号密码输入是否正确
	 */
	public List<user> selectByAccount(@Param("username")String username,@Param("password")String password);
	
	/*
	 * 用户注册
	 */
	public void insertAccount(@Param("username")String username,@Param("password")String password,@Param("hobbies")String hobbies,@Param("tel")String tel,@Param("accountIdentity")String accountIdentity,@Param("location")String location,@Param("gender")String gender,@Param("money")int money);
	/*
	 * 查询页面访问次数
	 */
	@Select("SELECT * FROM tb_user WHERE username=#{temp}")
	public List<user> selectLoadInNum(@Param("temp")String temp);
	
	/*
	 * 修改用户个人信息\没改密码。
	 */
	public void updateUserInfo(@Param("username")String username,@Param("hobbies")String hobbies,@Param("tel")String tel,@Param("location")String location,@Param("gender")String gender,@Param("id")int id);
	/*
	 *修改用户密码
	 */
	@Update("UPDATE tb_user SET password=#{password} WHERE username=#{targetUsername}")
	public void updatePassword(@Param("targetUsername")String targetUsername,@Param("password")String password);
	/*
	 * 用户注销账户
	 */
	@Delete("DELETE FROM tb_user WHERE username=#{username}")
	public void deleteAccount(@Param("username")String username);
	
	
	/*
	 * 修改资金额
	 */
	@Update("UPDATE tb_user SET money=#{money} WHERE username=#{username}")
	public void updateMoney(@Param("username")String username,@Param("money")int money);
	
}
